# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=optipng
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.7.6
pkgrel=1
pkgdesc="Compresses PNG files to a smaller size, without losing any information (mingw-w64)"
arch=('any')
url="http://optipng.sourceforge.net/"
license=("ZLIB")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-zlib")
options=('strip' 'staticlibs')
source=("https://downloads.sourceforge.net/sourceforge/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('4870631fcbd3825605f00a168b8debf44ea1cda8ef98a73e5411eee97199be80')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --with-system-libpng \
    --with-system-zlib

  make
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make prefix="${pkgdir}${MINGW_PREFIX}" mandir="${pkgdir}${MINGW_PREFIX}/share/man" install

  # Install license
  install -Dm644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
